<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台广告添加</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/Public/Admin/css/bootstrap.min14ed.css" rel="stylesheet">
    <link href="/Public/Admin/css/font-awesome.min93e3.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/Public/Admin/css/animate.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/style.min862f.css" rel="stylesheet">
    <link href="/Public/Admin/js/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/switchery/switchery.min.css" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加广告</h5>
                </div>
                <div class="ibox-content">
                    <form method="post" name="forma" id="forma" action="<?php echo U('ad/save');?>" class="form-horizontal" enctype="multipart/form-data">
                    <input type="hidden" name="id" value="<?php echo ($adInfo["id"]); ?>" />
                        <div class="form-group">
                            <label class="col-sm-2 control-label">排序</label>

                            <div class="col-sm-10">
                                <input type="text" name="sort" id="sort" class="form-control" value="<?php echo ($adInfo["sort"]); ?>">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">广告名称</label>

                            <div class="col-sm-10">
                                <input type="text" name="title" id="title" class="form-control" value="<?php echo ($adInfo["title"]); ?>">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">头像上传</label>

                            <div class="col-sm-10">
                                <input type="file" name="imgs" value="<?php echo ($adInfo["imgs"]); ?>"/>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">广告类型</label>

                            <div class="col-sm-10">
                                <select class="form-control m-b" name="type" id="type">
                                    <option value="">==请选择广告类型==</option>
                                        <option value="图片">图片</option>
                                        <option value="动画">动画</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">所属版位</label>
                            <div class="col-sm-10">
                                <select class="form-control m-b" name="position">
                                    <option value="">==请选择版位==</option>
                                    <?php if(is_array($posInfo)): $i = 0; $__LIST__ = $posInfo;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>" <?php if($vo['id'] == $adInfo['position'] ): ?>selected<?php endif; ?>><?php echo ($vo["title"]); ?>——<?php echo ($vo["type"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">下线时间：</label>
                            <div class="col-sm-10">
                                <input type="text" class="laydate-icon input w50" id="downtime" name="downtime" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" value="<?php echo ($adInfo["downtime"]); ?>" data-validate="required:日期不能为空" style="padding:10px!important; height:auto!important;border:1px solid #ddd!important;" />
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态</label>

                            <div class="col-sm-10">
                                <input type="checkbox" value="1" name="status" id="status" class="js-switch" <?php if($adInfo['status'] == 1): ?>checked<?php endif; ?> checked>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">保存内容</button>
                                <button class="btn btn-white" type="reset"  onclick="history.go(-1)">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/Public/Admin/js/jquery.min.js"></script>
<script src="/Public/Admin/js/bootstrap.min.js"></script>
<script src="/Public/Admin/js/plugins/layer/layer.min.js"></script>
<script src="/Public/Admin/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="/Public/Admin/js/plugins/switchery/switchery.min.js"></script>
<script src="/Public/Admin/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/Public/Admin/js/plugins/validate/messages_zh.min.js"></script>
<script src="/Public/Admin/js/common.js"></script>
<script src="/Public/Admin/js/plugins/layer/laydate/laydate.js"></script>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<script>
$(function(){
        $("#forma").validate({
            rules:{
                title:"required",
                type:"required",
                position:"required"
            },
            messages:{
                title:'广告名不能为空!',
                type:'广告类型不能为空',
                position:'广告版位不能为空！'
            },
            submitHandler: function (form){
                var forma = new FormData(document.getElementById('forma'));
                console.log(forma);
                $.ajax({
                        url:$(form).attr('action'),
                        type:'post',
                        dataType:'json',
                        data:forma,
                        cache:false,
                        processData:false,
                        contentType:false,
                        success:function(data){
                           if(data.status > 0){
                               common.error(data.msg);
                           }else{
                               common.success(data.msg,"<?php echo U("ad/index");?>");
                           }
                        }
                });
            }
        });
    });
    var elem = document.querySelector('.js-switch');
    var switchery = new Switchery(elem, { });
</script>
</html>